import { Popup } from '@nutui/nutui-react-taro';
import { Button, View } from '@tarojs/components';
import './index.less';

interface IProps {
  visible: boolean;
  onClose: Function;
  onConfirm: Function;
  content: string;
}

const AlterComp = (props: IProps) => {
  const {
    visible = false,
    onClose,
    onConfirm,
    content,
  } = props;

  const hidePopup = () => {
    onClose && onClose();
  };

  const confirm = () => {
    onConfirm && onConfirm();
  };

  return (
    <Popup
      visible={ visible }
      onClose={ hidePopup }
      closeable
      className='logout-popup'
    >
      <View className='title font-bold'>温馨提示</View>
      <View className='main'>{ content }</View>
      <View className='btn-group'>
        <Button className='cancel' onClick={ hidePopup }>
          取消
        </Button>
        <Button className='confirm' onClick={ confirm }>
          确定
        </Button>
      </View>
    </Popup>
  );
};

export default AlterComp;